package com.ossjk.api.controller;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.ossjk.core.base.controller.BaseController;
import com.ossjk.core.util.Constant;
import com.ossjk.core.vo.ResponseBean;
import com.ossjk.oa.attendance.entity.Atdreport;
import com.ossjk.oa.attendance.service.IAtdreportService;
import com.ossjk.oa.attendance.service.impl.AtdreportServiceImpl;
import com.ossjk.oa.system.entity.Token;
import com.ossjk.oa.system.service.impl.AreaServiceImpl;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 请假接口1234567890-
 
 我是组长
  我是组员
  3456768798iufdsghfkasldfahfhsdfkjh卡拉胶
 */
@Api(description = "请假接口")
@RestController
@RequestMapping("/api/leave")
public class LeaveApiContriller extends BaseController {
    @Autowired
    private IAtdreportService iAtdreportService;

    //使用postman，是一个软件。也有谷歌浏览器插件

    /**
     * @param month
     * @param eid
     * @return
     */
    @ApiOperation(value = "请假列表", notes = "请假列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "month", value = "月份", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "eid", value = "用户", paramType = "query", dataType = "String")
    })
    @GetMapping("getLeaveApplication")
    public ResponseBean<List<Atdreport>> getLeaveApplication(String month, String eid, HttpServletRequest request) {

        List list = new ArrayList();
        // 类型：1-加班、2-带薪年假、3-带薪调休、4-普通请假，5-外出
        list.add(2);
        list.add(3);
        list.add(4);
        Wrapper wrapper = Condition.create().like("date", month).eq("eid", eid).in("type", list);


        return (ResponseBean<List<Atdreport>>) responseSuccess(iAtdreportService.selectList(wrapper));
    }

    //逻辑删除：也是删除的一种，只是没有把数据从数据库中真实的删除，而是把数据使用一个字段记录起来，记录为删除状态：字段叫isdelete逻辑删除 1-未删除、2-已删除
    //delete方法变成update 语句 没解决
    @GetMapping("delete")
    public Object delete(Atdreport atdreport) {
        System.out.println(atdreport);
        return null;
    }


}
